from tkinter import *
from tkinter import colorchooser
from tkinter.filedialog import *

root = Tk()
root.title('颜色选择')
root.geometry('200x200+200+200')

# 颜色选择框
# def test1():
#     s1 = colorchooser.askcolor(color='red',title='颜色选择框的标题') # 返回一个元组
#     print(s1)
#     root.config(bg=s1[1])
#     l['bg'] = s1[1]

# b1 = Button(root,text='选择颜色',command=test1).pack()
# l = Label(root,text='hello',width=100,height=100).pack()

# 文件选择框
def test1():
    filecontent = askopenfile(title='上传文件',initialdir="f:",filetype=[("文本文件",".txt",".doc")],mode='a')
    fs = Open(filecontent)
    
    lable = Label(root,width=100,height=10,bg='yellow',text=filecontent).pack()

Button(root,text='上传文件',command=test1).pack()
lable = Label(root,width=10,height=10,bg='yellow').pack()


root.mainloop()